/**
 * 
 */
package cr.co.tse.padronelectoral;

import java.util.HashMap;
import java.util.Map;

import cr.co.tse.padronelectoral.domain.CodigoElectoralInscrito;
import cr.co.tse.padronelectoral.parser.RowProcessorHandler;

/**
 * Implementation to Patron Electoral csv row processor.
 * @author jsanca
 *
 */
public class DistelecRowProcessorHandler implements RowProcessorHandler {

	private Map<Integer, CodigoElectoralInscrito> map = new HashMap<Integer, CodigoElectoralInscrito> ();
	
	public DistelecRowProcessorHandler(Map<Integer, CodigoElectoralInscrito> map) {
		
		if (null != map) {
			
			this.map = map;
		}
	} // PatronElectoralRowProcessorHandler.

	/* (non-Javadoc)
	 * @see cr.co.tse.padronelectroral.parser.RowProcessorHandler#process(java.lang.String[])
	 */
	@Override
	public void process(String[] row) {

		int id = Integer.parseInt(row[0]);
		CodigoElectoralInscrito codigoElectoralInscrito = 
			new CodigoElectoralInscrito ();
		
		codigoElectoralInscrito.setId(id);
		codigoElectoralInscrito.setProvincia(row[1]);
		codigoElectoralInscrito.setCanton(row[2]);
		codigoElectoralInscrito.setLugarElectroralInscrito(row[3]);
		
		this.map.put(id, codigoElectoralInscrito);
	} // process.

	public Map<Integer, CodigoElectoralInscrito> getMap() {
		return map;
	}

} // E:O:F:PatronElectoralRowProcessorHandler.
